package converter;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Controller;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@Controller
public class dateConverter implements Converter<String, Date> {

    @Override
    public Date convert(String source) {
        String dateFormat = "yyyy-MM-dd";
        SimpleDateFormat  simpleDateFormat = new SimpleDateFormat(dateFormat);
        Date date = null;
        try {
            date = simpleDateFormat.parse(source);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        return date;
    }
}
